<template>
	<view class="content">
		<!-- <view v-for="item in list" :key="item">{{item.price}}</view> -->
		<!-- <van-search
	  value={{value}}
	  
	  placeholder="请输入搜索关键词"
	 
	 
	> -->
		<view class="input" @click="goSousuo()" >
			<!-- <input v-model="value" class="textinput" type="text" placeholder="请输入搜索关键词" />


@search="onSearch"
			<view class="in" @click="getValue()">搜索</view> -->
			<van-search v-model="value" placeholder="请输入搜索关键词"   style="width: 100%;" />
			
		</view>
		<view class="swiper-class">
			<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="2000" :duration="500">
				<swiper-item v-for="(item,index) in info[0]" :key="index">
					<image class="bjimage" :src="item.imageurl"></image>
				</swiper-item>

			</swiper>
		</view>


<!-- <view class="jj">
			<jj :pctext='pctext' :pcjianjieimage='pcjianjieimage'></jj>
		</view> -->
		<view class="text_go">
			<van-grid>
				<van-grid-item icon="fire-o" @click="go_lunbo_men()" icon-color="#ee0a24" text="图册集" />
				<van-grid-item icon="hot-sale-o"  icon-color="#ee0a24" text="xxxx" />
				<van-grid-item icon="hot-o" icon-color="#ee0a24" text="xxxx" />
				<van-grid-item icon="hot-o" icon-color="#ee0a24" text="xxxx" />
			</van-grid>
		</view>
		<view class="center">
			
			<ct class="ct" v-for="item in infopush[0]"  :key="item.objectId" :infopush="item"></ct>
		</view>
		
		
		<!--  -->
		<view class="textlike">
			—— 成品示例 ——
		</view>
		<view class="shangp">

			<sp class="sp" v-for="item in searchedList_two" :key="item.objectId" :goodlist="item"></sp>
		</view>


	</view>
</template>

<script>
	export default {

		data() {
			return {
				list: [],
				searchedList: [],
				searchedList_two: [],
				value: '',
				isoff:true,
				pctext: [],
				pcjianjieimage: [],
				info: [

				],
				infopush:[
					
				]

			}
		},
		onReachBottom() {
			this.loadMoreContent();
		},
		onLoad() {
			this.lunboimage()
			this.pushds()
		},
		onShow() {
			if(this.isoff)
			{
				
			
			let url = `/1.1/classes/bscs`
			this.$get(url).then(res => {
				uni.stopPullDownRefresh()
				// console.log(res)
				let {
					results
				} = res
				if (results.length) {
					this.list = res.results
					
					this.searchedList = res.results

				}
				for (let i = 0; i < 6; i++) {
				
					this.searchedList_two.push(this.searchedList[i])
					
				}
				
			})
			this.onoff()
		}
		let urlo = `/1.1/classes/x_jianjie_image`
		this.$get(urlo).then(res => {
			uni.stopPullDownRefresh()
			this.pcjianjieimage = res.results[0]
			console.log(this.pcjianjieimage)
		
		})
		let url = `/1.1/classes/pctext`
		this.$get(url).then(res => {
			uni.stopPullDownRefresh()
			this.pctext = res.results[0]
		
		})

		},
		mounted() {
			// this.data()
		},
		methods: {
			go_lunbo_men(){
				uni.navigateTo({
				        url: `../lunbo/lunbo`
				      });
			},
			goSousuo(){
				
				uni.navigateTo({
				        url: `../sousuo/sousuo?focus=true`
				      });
				// uni.navigateTo({
				// 	url: `../sousuo/sousuo`
				// })
			},
			
			onoff(){
					this.isoff=false
			},
			loadMoreContent() {
				
				setTimeout(() => {
					
					if (this.searchedList_two.length == this.searchedList.length) {
						// console,log("我在这！！！")
						return
					}
					for (let i = 0; i < 4; i++) {
						let a=this.searchedList_two.length
						this.searchedList_two.push(this.searchedList[a ])
						if(this.searchedList_two.length==this.searchedList.length){
							return
						}
						console.log("我执行了2",this.searchedList_two)
					}
					
				}, 1)
			},
			onSearch(event) {
				this.searchedList === ''
				const text = event.detail
				// console.log("我在这",this.value)
				// console.log(text,this.list,this.searchedList)
				this.searchedList_two = this.list.filter(item => {
					// console.log(item.xiangqing,"执行了")
					return item.xiangqing.includes(text);
				});
				console.log(this.searchedList)
				for(let i=0;i<this.searchedList_two.length;i++)
				{
					var url = `https://r5ctn9z9.lc-cn-n1-shared.com/1.1/classes/bscs?where={"xiangqing":"${this.searchedList_two[i].xiangqing}"}`;
					var header = {
						"X-LC-Id": "r5CTN9z96pCW8mI8fx9YxOmw-gzGzoHsz",
						"X-LC-Key": "8gSsl4Sz0ILMiQeMNMA8xQqg",
						'Content-Type': 'application/json'
					};
					
					uni.request({
						url: url,
						method: 'GET',
						header: header,
					
						success: function(res) {
							
							console.log(res)
							var urll =	`https://r5ctn9z9.lc-cn-n1-shared.com/1.1/classes/bscs/` + res.data.results[0].objectId;
								
							var data = {
								sou:res.data.results[0].sou+1
							}
							uni.request({
								url: `https://r5ctn9z9.lc-cn-n1-shared.com/1.1/classes/bscs/` + res.data.results[0].objectId,
								method: 'PUT',
								header: header,
								data: data,
								success: function(res) {
									console.log("成功", res)
					
								},
								fail:function(err){
									console.log(err)
								}
							})
					
						}
					
					})
				}
			
			},
			lunboimage() {
				let url = `/1.1/classes/lunbo_image`
				this.$get(url).then(res => {

					this.info.push(res.results)
				})
				console.log(this.info)
			},
			pushds() {
				let url = `/1.1/classes/pushds`
				this.$get(url).then(res => {
			
					this.infopush.push(res.results)
				})
				console.log(this.infopush)
			}
			// ct(){
			// 	let url = `/1.1/classes/lunbo_image`
			// 	this.$get(url).then(res => {
				
			// 		this.info.push(res.results)
			// 	})
			// 	console.log(this.info)
			// }


		}
	}
</script>

<style>
	.text_go{
		margin-top: 2vw;
	}
	.content{
			background-color: ghostwhite;
			
	}
	.textlike{
		font-size: 18px;
		text-align: center;
		color: grey;
		margin-top: 5vw;
	}
	.center{display: flex;
			margin-top: 3vw;
			flex-wrap: wrap;
			justify-content: space-around ;
			
		
			}
	.shangp {
		
		display: flex;
	margin-top: 5vw;
		flex-wrap: wrap;
		/* justify-content: space-around; */
		/* flex-direction: column; */
		 align-items: flex-start; 
		/* padding: 15upx; */
		/* width: 100px; */

	}
	.ct{
		margin-left: 1vw;
		/* margin-right: 8px; */
		flex-grow: 3;
		margin-top: 1vw;
		
		display: flex;
		/* width: 40%; */
		/* box-sizing: border-box; */
	}
	.sp {
	margin-left: 8px;
	/* margin-right: 8px; */
	flex: 1;
	margin-top: 6px;
	
	display: flex;
	width: 40%;
	box-sizing: border-box;
	}

	.sp:last-child {
		margin-right: auto;
	}

	.input {
		width: 90vw;
		
		display: flex;
		margin: 0 auto;
	}

	.textinput {
		/* margin-left: 20px; */

		width: 260px;
		border: 1px solid rgb(217, 217, 217);
	}
	.jj {
		margin-top: 10px;
	}

	.in {

		/* font-size: 13px; */
		/* margin-right: 90px; */
		/* float: right; */
		/* border: 0; */
		margin-left: 10px;
		width: 40px;
		border: 1px solid rgb(217, 217, 217);
		text-align: center;
		border-radius: 20%;
		background-color: rgb(245, 245, 245);
	}

	.swiper {
		/* margin-top: 1rem; */
		height: 240px;

		/* height: 304px; */
	}

	.bjimage {
		width: 100vw;

	}
</style>